<template>
    <view>
        <!-- #ifdef MP-WEIXIN -->
        <top-nav :inner-title="title" is-show-back="true" is-fixed="true" :navH="navH" :n="n" is-white="bg-white" :opacity="opacity"></top-nav>
        <view  :style="{height:navH + 'px'}"></view>
        <!-- #endif -->  
      <!--  <view class="load_before" v-if="hideOver" :style="{opacity: loadOver ? .5 : 0}">
            
        </view> -->
        <view class='content'>
            <scroll-view>
                <block v-if="showSelect">
                      <view class="time-box">
                            <view class="time-mask" @click="closeClassEvent()" @touchmove.stop.prevent="moveHandle"></view>
                            <view class="time-select">
                              <view class="time-title"><text>{{classText}}</text></view>
                              <view class="time-scroll">
                                <scroll-view class="time-scroll-left" scroll-y style="height: 400rpx;">
                                  <block v-for="(item,index) in classTypeList" :key="index">
                                    <view :class="item.current == 1 ? 'time-select-view':''" @click="selectTypeEvent($event)" :data-idx="index"><text>{{item.text}}</text></view>
                                  </block>
                                </scroll-view>
                                <scroll-view class="time-scroll-right"  scroll-y style="height: 400rpx;">
                                      <block v-for="(item,index) in classTimeList" :key="index">
                                            <view @click="selectTimeEvent($event)" :data-idx="index" v-if="startServiceTime != 0">
                                                <view>{{item}}</view>
                                                <icon :class="timeIdx == index && selectClass != '' ? 'picker_chosed' : ''"></icon>
                                            </view>
                                            <view @click="selectTimeEvent($event)" :data-idx="index" v-else>
                                                <view>{{item.finish_time}}</view>
                                                <icon :class="timeIdx == index && selectClass != '' ? 'picker_chosed' : ''"></icon>
                                            </view>
                                      </block>
                                </scroll-view>
                              </view>
                            </view>
                      </view>
                </block>
                <block v-if=" !is_master && header=='buy_together' ">
                    <view class="buy-info">
                        <view class="status_title" v-if="group_status == 1">已完成选购，等待发起人提交订单</view>
                        <view class='status-manager'>
                            <view class="steps">
                                <view class="dot_content">
                                    <view class="dot_line"></view>
                                    <view class="dot_round black">1</view>
                                    <view class="dot_line" :class="group_status > 1 ? 'black' : 'gray' "></view>
                                </view>
                                <view class="status">完成选购</view>
                            </view>
                            <view class="steps">
                                <view class="dot_content">
                                    <view class="dot_line" :class="group_status > 1 ? 'black' : 'gray' "></view>
                                    <view class="dot_round" :class="group_status > 1 ? 'black' : 'gray' ">2</view>
                                    <view class="dot_line" :class="group_status > 2 ? 'black' : 'gray' "></view>
                                </view>
                                <view class="status" :class="group_status > 1 ? 'black' : 'gray' ">提交订单</view>
                            </view>
                            <view class="steps">
                                <view class="dot_content">
                                    <view class="dot_line" :class="group_status > 2 ? 'black' : 'gray' "></view>
                                    <view class="dot_round" :class="group_status > 2 ? 'black' : 'gray' ">3</view>
                                    <view class="dot_line gray"></view>
                                </view>
                                <view class="status" :class="group_status > 2 ? 'black' : 'gray' ">完成拼单</view>
                            </view>
                        </view>
                    </view>
                
                    <view class='trans_tips'>
                        <view>您需支付<text class='red-text'>¥{{group_list[0].money}}</text></view>
                        <view class='gray-text'>建议使用微信给<text class='black-text'>{{master_name}}（发起人）</text>转账</view>
                    </view>
                </block>
                <block v-else>
                     <view  class="start_service_time" v-if=" startServiceTime != '' && startServiceTime != 0  && storeInfo.disable "><view class='time'>{{startServiceTime}}</view> <view>开始{{serviceType>0 ? '取餐' : '配送'}}</view></view>
                    <view class='trans_bg'>
                            <block v-if="storeInfo.open_oneself == 1 && sid != 'group' && sid !='share_group'">
                                <view class="tab">
                                    <view class="tab-item" :class="serviceType == 0?'type1':'type3'" @click="serviceTypeEvent(0)">
                                        <view>外卖配送</view>
                                        <view class='red_dot' v-if="typeCk<2"></view>
                                    </view>
                                    <view class="tab-item" :class="serviceType == 0?'type2':'type4'" @click="serviceTypeEvent(1)">
                                        <view>到店自取</view>
                                        <view class="red-badge flex" v-if="serviceType == 0">省配送费</view>
                                        <view class='red_dot' v-if="typeCk<2"></view>
                                    </view>
                                </view>
                            </block>
                            <block v-if="storeInfo.open_oneself == 2 && sid != 'group' && sid !='share_group'">
                                    <view class="only-oneself">到店自取</view>
                            </block>
                           
                            <view style="clear:both"></view>
                            <block v-if="serviceType > 0 && sid != 'group' && sid !='share_group'">
                                <view class="selfInfo" :style='{marginTop:startServiceTime != "" && startServiceTime != 0 && storeInfo.disable ? "20rpx" :"20rpx"}'>
                                    <view class="storeAddress">
                                        <view class="storeAddressLeft" @click="goMobile()">
                                            <text class="addr">{{storeInfo.address}}</text>
                                            <text class="phone">联系电话 {{storeInfo.mobile}}</text>
                                        </view>
                                        <view class="storeAddressIcon b1">
                                            <icon class="arr_right"></icon>
                                        </view>
                                    </view>
                                    <view class="selectTime" @click="selectClassEvent()">
                                        <view class="storeAddressLeft">
                                            <view>自取时间</view>
                                            <block v-if="selectClass==''">
                                                <view class='green_text'>下单必选</view>
                                            </block>
                                            <block v-else>
                                                <view class='green_text'>{{selectClass}}</view>
                                            </block>
                                            
                                        </view>
                                        <view class="storeAddressIcon">
                                            <icon class="arr_right"></icon>
                                        </view>
                                    </view>
                                    <view class="agreement">
                                        <image @click="readRemark()" :src="isRead?'http://juhuijia2.birdback.org/mapi/i/run/no_xuanzhong@3x.png':'http://img1.birdback.org/a/0b/52/0b52d70bb2aea2ff850fb57ee416a891.png'"></image>
                                        <text class="a6">同意</text>
                                        <text @click="goRemark()" class="link">《到店自取服务协议》</text>
                                    </view>
                                </view>
                            </block>
                            <block v-else>
                                <view class='address' :style='{marginTop: startServiceTime != "" && startServiceTime != 0 && storeInfo.disable ? "20rpx" :"0"}'>
                                    <view class='address-list'>
                                        <block v-if='!address.id'>
                                            <view class="addr-body" @click='addressEvent(1)'>
                                                <view class='address-add'>
                                                    <view class='icon'></view>
                                                    <view class='text'>新增收货地址</view>
                                                </view>
                                            </view>
                                            <view class='jt b1'>
                                                <icon class="arr_right"></icon>
                                            </view>
                                        </block>
                                        <block v-else>
                                            <view class='address-item' :data-id='address.id' @click='addressEvent(2)'>
                                                <view class='info'>
                                                    <block v-if="address.school_type == 1">
                                                        <view class='address-addr'>{{address.school_name}} {{address.addr_name}} {{address.num}}</view>
                                                    </block>
                                                    <block v-else>
                                                        <view class='address-addr'>{{address.addr_name}} {{address.num}}</view>
                                                    </block>
                                                    <view class='my'>
                                                        <text class='name'>{{address.name}}</text>
                                                        <text class='sex'>{{address.sex == 1 ? "男同学":"女同学"}}</text>
                                                        <view class='phone'>{{address.phone}}</view>
                                                    </view>
                                                </view>
                                                <view class='jt b1'>
                                                    <icon class="arr_right"></icon>
                                                </view>
                                            </view>
                                        </block>
                                    </view>
                                    <view class='selectTime' @click="selectClassEvent()">
                                        <block v-if="showSelectBtn">
                                            <view class="storeAddressLeft">
                                                <view class="text">送达时间</view>
                                                <block v-if="selectClass == ''">
                                                    <view class="green_text">下单必选</view>
                                                </block>
                                                <block v-else>
                                                    <view class='green_text'>{{selectClass}}</view>
                                                </block>
                                                
                                            </view>
                                            <view class="storeAddressIcon">
                                                <icon class="arr_right"></icon>
                                            </view>
                                        </block>
                                        <block v-else>
                                            <view class="storeAddressLeft">         
                                                <block v-if="sid == 'group' || sid == 'share_group'"> <!-- 开车订单送达时间 -->   
                                                    <view class="text">送达时间</view>
                                                    <view class="green_text">大约 {{selectDate}} {{selectClass.finish_time}} 送达</view>
                                                </block>
                                                <block v-else>
                                                    <view class="text">送达时间</view>
                                                    <view>尽快送达</view>
                                                </block>
                                            </view>
                                        </block>
                                    </view>
                                </view>
                            </block> 
                    </view>
                </block>
                
                <view class='fujia' v-if="serviceType>0">
                    <view class='item'>
                        <block v-if="storeInfo.id != '1758' && storeInfo.id != '1752' && storeInfo.id != '1753' && storeInfo.id != '1751' && storeInfo.id != '1750'">
                            <view class='tc' data-id="1" @click='changeIsPack(1)'>
                                <text class=''>堂食</text>
                                <view class="ck-icon" :class=" is_pack==1 ? 'checked' : '' "></view>
                            </view>
                        </block>
                        <view class='db' data-id="0" @click='changeIsPack(0)'>
                            <text class=''>打包</text>
                            <view class="ck-icon" :class=" is_pack==0 ? 'checked' : ''"></view>
                        </view>
                    </view> 
                </view>
                 
                <view class='buy-info'>
                    <view class='title flex_Row store_head'  @click='openStore()' :data-storeid='storeInfo.id'>
                        <view class="title_left flex_Row">
                            <image class='icon' :src='storeInfo.icon'></image>
                            <view class='text'>{{storeInfo.shop_name}}</view>
                            <view class='jt'>
                                <icon class="arr_right"></icon>
                            </view>
                        </view> 
                        <view class="status-button get_oneself" v-if="storeInfo.open_oneself != 0">
                            <view class="green"><text>支持自取</text></view>
                        </view>
                    </view>
                    <block v-if="header=='buy_together'">
                        <view class="buy_info_list">
                            <view class="group_person" v-for="(item,index) in  group_list" :key="index" :style='{display:(!showMore && index == 0) || showMore ? "block" : "none" }'>
                                <view class="list_head title flex_Row">
                                    <view class='title_left flex_Row'>
                                        <image class='face' :src="item.face"></image>
                                        <text class="nickname ellipsis">{{item.nickname}}</text>
                                        <text class="tips" v-if="index == 0">(我)</text>
                                    </view>
                                    <block v-if="index == 0">
                                    <view class='title_right flex_Row'>
                                        <button class="gray_bt" v-if=" !is_master && group_status == 1 " @click='outGroup()'>退出拼单</button>
                                        <button class="gray_bt" v-if=" group_status == 1 || ( is_master && group_status == 2 ) " @click='changeGroup()'>修改商品</button>
                                    </view> 
                                    </block>   
                                </view>
                                <view class='buy-list'>
                                    <block v-for="(item,index) in item.goods_list" :key="id">
                                        <view class='item'>
                                        <view class='item-left'>
                                            <image :src='item.img_path'></image>
                                        </view>
                                        <view class='item-right'>
                                            <view class='name'>
                                            <view class='text'>{{item.name}}</view>
                                            <view class='price'>￥{{item.money}}</view>
                                            </view>
                                            <view class='setting'>{{item.showDesc}}</view>
                                            <view class='num'>
                                            <view class='text'>x{{item.num}}</view>
                                            <block v-if="item.real_price > 0">
                                                <view class='price'>￥{{item.real_price}}</view>
                                            </block>
                                            </view>
                                        </view>
                                        </view>
                                    </block>
                                </view>
                                <view class='settlement'>
                                    <view class='settlement-box buy-detail-item'>  
                                        <view class='sum'>
                                            小计
                                            <text>￥{{item.money}}</text>
                                        </view>
                                        <view class='text'>计算规则 <view class="tips_question" @click="showTip()"></view></view>
                                    </view>
                                </view>
                            </view>
                        </view>
                    </block>
                    <block v-if=" !header || header == '' ">
                        <view class='buy-list' :style='{height:goods_list.length > 3 && !showMore ? "507rpx":""}'>
                            <block v-for='(item,index) in goods_list' :key="index">
                                <view class='item'>
                                    <view class='item-left'>
                                        <image :src='item.icon'></image>
                                    </view>
                                    <view class='item-right'>
                                        <view class='name'>
                                            <view class='text'>{{item.name}}</view>
                                            <view class='price'>￥{{item.price}}</view>
                                        </view>
                                        <view class='setting'>{{item.showDesc}}</view>
                                        <view class='num'>
                                            <view class='text'>x{{item.num}}</view>
                                            <block v-if="item.real_price > 0">
                                                <view class='price'>￥{{item.real_price}}</view>
                                            </block>
                                        </view>
                                    </view>
                                </view>
                            </block>
                        </view>
                    </block>
                    <view class='buy-detail'>
                        <block v-if='goods_list.length > 3 || group_list.length>1'>
                            <view class='button_more' @click='showMoreF()'>
                            <text>{{ showMore ? '点击收起' : '展示更多' }}</text>
                            <icon :class='showMore ? "ck":""'></icon>
                            </view>
                        </block>
                        <view class="buy_detail_info"> 
                            <view class='buy-detail-item' v-if="is_pack==0 || serviceType == 0 ">
                                <view class='text'>包装费</view>
                                <view class='price'>￥{{package_fee}}</view>
                            </view>
                            <block v-if="serviceType == 0 ">
                                <view class='buy-detail-item' v-if=" serviceType == 0 ">
                                    <view class='text'>配送费</view>
                                    <view class='price'>￥{{send_price}}</view>
                                </view>
                            </block>
                            <block v-if='mPrice > 0'>
                                <view class='buy-detail-item'>
                                    <view class='youhui'>
                                        <view class='cut_icon'>减</view>
                                        <text>满减优惠</text>
                                    </view>
                                    <view class='youhui-price'>-￥{{mPrice}}</view>
                                </view>
                            </block>
                            <block v-if='zkPrice > 0'>
                                <view class='buy-detail-item'>
                                    <view class='youhui'>
                                        <view class='discount'></view>
                                        <text>折扣优惠</text>
                                    </view>
                                    <view class='youhui-price'>-￥{{zkPrice}}</view>
                                </view>
                            </block>
                            <block v-if="(is_master || header != 'buy_together') && storeInfo.use_red_packet == 0 ">
                                <block v-if="!isRegisted">
                                    <!-- #ifdef MP-WEIXIN -->
                                     <button class="buy-detail-item bind_item gray_text" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
                                         <view class='youhui'>
                                             <text>红包</text>
                                         </view>
                                         <view class="red_bg_text flex"><view class="white_packet"></view>绑定手机号查看红包</view> 
                                     </button>  
                                    <!-- #endif -->
                                    <!-- #ifdef MP-ALIPAY -->
                                     <button class="buy-detail-item bind_item gray_text" open-type="getAuthorize" @getAuthorize="onGetAuthorize" @error="onAuthError" scope='phoneNumber'>
                                         <view class='youhui'>
                                             <text>红包</text>
                                         </view>
                                         <view class="red_bg_text flex"><view class="white_packet"></view>绑定手机号查看红包</view>
                                     </button>  
                                    <!-- #endif -->                                   
                                </block>
                                <block v-else>
                                    <block v-if="serviceType==0 && address.length <= 0">
                                        <view class='buy-detail-item bind_item'  @click='addressEvent(1)'>
                                            <view class='youhui'>
                                                <text>红包</text>
                                            </view>
                                             <view class="gray_text">请先填写收货地址</view/>
                                        </view>
                                    </block>
                                    <block v-else>
                                        <view class='buy-detail-item bind_item'  @click='goRedPacket()'>
                                            <view class='youhui'>
                                                <text>红包</text>
                                            </view>
                                            <view class="gray_text flex">
                                                 <text class="red_text" v-if="packet_val>0">-¥{{packet_val}} </text>
                                                 <text v-else-if="useful.length>0"><text class="red_text">{{useful.length}}个可用红包</text></text>
                                                 <text v-else>无可使用红包</text>
                                                 <icon class="arr_right"></icon>
                                            </view>
                                        </view>
                                    </block>
                                </block>

                            </block>
                        </view>
                        
                        <view class='settlement'>
                            <view class='settlement-box'>
                                <view class='wz'>
                                    <block v-if='yhPrice > 0'>
                                        <view class='youhui'>已优惠￥{{Number(yhPrice)+Number(packet_val)}}</view>
                                    </block>
                                    <view class='sum'>
                                        合计
                                       <text>￥
                                       <block v-if="(payPrice-packet_val).toFixed(2)<=0">0.01</block>
                                       <block v-else>{{(payPrice-packet_val).toFixed(2)}}</block>
                                       </text>
                                    </view>
                                </view>
                                <view class="youhui" v-if="is_disable_m_goods > 0">满减活动和折扣商品不同享</view>
                            </view>
                        </view>
                    </view>
                </view>
                <block v-if=" is_master || header != 'buy_together' ">
                    <view class='fujia'>
                        <view class='option'>
                            <view class='item'>
                                <text>支付方式</text>
                                <text>在线支付</text>
                            </view>
                        </view>
                        <view class='option'>
                            <view class='item' @click="remarkEvent()">
                                <text class='no-flex'>备注</text>
                                <input maxlength='50' disabled type='text' placeholder='口味、偏好等要求' :value='remark'></input>
                                <icon class="arr_right"></icon>
                            </view>
                        </view>
                        
                        <view class='option' v-if="!(serviceType>0 && is_pack == 1)">
                            <view @click="selectCan()" class='item'>
                                    <text>餐具数量</text>
                                    <view v-if="ISCAN == 0 "> 
                                        <icon class="env_icon"></icon>
                                        <text style="color:#00B89D;font-size:24rpx;margin-right:10rpx;">支持环保，减少一次性餐具使用</text>
                                    </view>
                                    <text v-if="ISCAN == 1 &&  !canArr[canSel]">依据餐量提供</text>
                                    <block v-else>
                                        <text v-if='canArr[canSel]'>{{ canArr[canSel] }}{{canSel == 0 ? '' : '套'}}</text>
                                        <text v-else> 必选</text>
                                    </block>   
                                    <icon class="arr_right"></icon>
                            </view>
                        </view>
                        
                    </view>
                    <view class="bottom_notice">
                       <!-- <block v-if="is_disable_m_goods > 0">
                          <view class="discount-notice">
                              <image src="http://juhuijia2.birdback.org/mapi/i/mjtip@3x.png"></image>
                              <text>满减优惠与折扣商品不能同享</text>
                          </view>
                        </block> -->
                        <view v-if=" is_pack==0 && (serviceType == 2 || serviceType == 1) " class="pack_tips">打包会收取餐盒费噢</view>
                    </view>
                    <view class='box'></view>
                    <view class='buyinfo' v-if=" (header == 'buy_together' && is_master) || header=='' ">
                        <view class='buyinfo-left'>
                            <view class="white_text">
                                <text>合计</text> 
                                <text class="sum">￥
                                    <block v-if="(payPrice-packet_val).toFixed(2)<=0">0.01</block>
                                    <block v-else>{{(payPrice-packet_val).toFixed(2)}}</block>
                                </text>
                            </view>
                            <block v-if='yhPrice > 0'>
                                <text class="gray_text">已优惠￥{{Number(yhPrice)+Number(packet_val)}}</text>
                            </block>
                        </view>
                        <view class='buyinfo-button'>
                            <!-- //外卖中的自取 -->
                            <block v-if="serviceType == 1 && sid != 'group' && sid !='share_group' && !firstOpenOneself">  
                                    <text @click='showOpenOnselfBox()'>提交订单</text>
                            </block>
                            <block v-else>
                                    <text @click='submitAdd()'>提交订单</text>
                            </block>
                        </view>
                    </view>
                </block>
            </scroll-view>
        </view>
        <view class="wxapp_login" v-if="showWxappLogin" >
            <view class="wxapp_login_maks" @touchmove.stop.prevent="moveHandle"></view>
            <view class="wxapp_login_view">
              
              <!-- #ifdef MP-WEIXIN -->
              <button class="wxapp_login_button" @getphonenumber="getPhoneNumber" open-type="getPhoneNumber"></button>
              <!-- #endif -->
              <!-- #ifdef MP-ALIPAY -->
              <button class="wxapp_login_button" open-type="getAuthorize" @getAuthorize="onGetAuthorize" @error="onAuthError" scope='phoneNumber'>
                   <!-- <image src=""></image> -->
              </button>  
              <!-- #endif -->
            </view>
        </view>
        <view class="open_oneself_box" v-if="openOnselfBoxShow">
            <view class="open_oneself_mask" @click="closeOpenOnselfBox()" @touchmove.stop.prevent="moveHandle"></view>
            <view class="open_oneself_content">
                <view class='bar title'>确认到店自取</view>
                <view class="bar tips">
                    <view>到店自取不提供配送服务，需要本人到店或指定地址自取哦！</view>
                </view>
                <view class="bar">      
                    <button class="cancel_open_oneself" @click="closeOpenOnselfBox()">取消</button>
                    <button class="confirm_open_oneself" @click='orderAdd()'>确定自取</button>
                </view>
            </view>
        </view>
        <view class="open_oneself_box" v-if="wxBindPhoneShow">
            <view class="open_oneself_mask" @touchmove.stop.prevent="moveHandle"></view>
            <view class="open_oneself_content">
                <view class='bar title'>获取手机号失败，请手动输入手机号</view>
                <view class="bar title">
                    <input :value='wxBindPhone' placeholder='请输入手机号' maxlength='11' type='number' @click='phoneEvent()'></input>
                </view>
                <view class="bar tips required">
                    <view class="" v-if="wrongNumber"> 请输入正确的手机号 </view>
                </view>
                <view class="bar">      
                    <button class="confirm_open_oneself" @click='closeWxBindPhoneShow($event)' :data-id="wxBindPhone">确定</button>
                </view>
            </view>
        </view>
        <view class="open_oneself_box narrow_bottom" v-if="showChangeToDe">
            <view class="open_oneself_mask" @touchmove.stop.prevent="moveHandle"></view>
            <view class="open_oneself_content">
                <view class='bar title'>还差¥{{storeInfo.start_send_price - priceNoSend}}达到外卖起送价</view>
                <view class="bar tips">
                    <view>商品+包装费需要满¥{{storeInfo.start_send_price}}才能「外卖配送」</view>
                </view>
                <view class="bar column_bt">      
                    <button class="confirm_open_oneself" @click='closeToDe(0)'>继续「到店自取」</button>
                    <button class="cancel_open_oneself" @click='closeToDe(1)'>去添加商品</button>
                </view>
            </view>
        </view>
        <view class='group-detail-box' v-if="showCanBox">
                <view class="group-mask"></view>
                <view class="group-detail-medium white_bg">
                    <view class="content">
                      <text>后续下单您是否都需要餐具？</text>
                      <text>（依据餐量提供）</text>
                    </view>
                    <view class="bottom flex_Row">
                        <button class="black_text" hover-class="none" @click="closeCanBox()">不需要</button>
                        <button class="green_text" hover-class="none" @click="confirmCanBox()">需要</button>
                    </view>
                </view>
        </view>
        <view class='group-detail-box'v-if="showRule">
            <view class="group-mask"></view>
            <view class="group-detail-medium">
                <view class='list bg'>  
                    <view class="group-detail-title">优惠计算规则</view>
                    <view class="group-item">
                        1.满减优惠金额等活动，根据每位拼友选购的商品价格，按金额比例分摊给每位拼友。
                        2.折扣菜/第二份半价菜优惠金额，根据每位拼友选购的商品原价，按金额比例分摊给每位拼友。
                    </view>
                    <view class="group-detail-title">配送费计算规则</view>
                    <view class="group-item">
                        配送费只按照1笔订单收取，根据每位拼友选购的商品价格，按金额比例分摊给每位拼友。
                    </view>
                    <view class="group-detail-title">包装费计算规则</view>
                    <view class="group-item">
                        包装费根据每位拼友的选购商品分别进行计算，不会进行平均分配。
                    </view>
                </view>
                <view class='close_together' @click='closeShowRule()'>
                </view>
            </view>
        </view>
        <view class="address_box" :style="{top: showAddressBox ? '0' : '100%'}">
            <view class="mask" @click="closeAddressBox()"></view>
            <view class="address_content">
                <view class="address_head">
                    <text @click="closeAddressBox()">取消</text>
                    <view class="title">我的收货地址</view>
                </view>
                <block v-if='list.length > 0'>
                    <view class="item_out" style="height: 700rpx;">
                        <block  v-for='(item,index) in list' :key="index">
                            <view class='item'> 
                                <view class="address_left" @click='active(item)'>
                                    <view class='active'>
                                        <view :class='item.is_active == 1?"ck":""'></view>
                                    </view>
                                    <view class='info' >
                                        <block v-if="item.school_type == 1">
                                            <view class='address'>{{item.school_name}} {{item.addr_name}} {{item.num}}</view>
                                        </block>
                                        <block v-else>
                                            <view class='address'>{{item.addr_name}} {{item.num}}</view>
                                        </block>
                                        <view class='my'>
                                            <text class='name'>{{item.name}}</text>
                                            <text class='sex'>{{item.sex == 1?"男同学":"女同学"}}</text>
                                            <view class='phone'>{{item.phone}}</view>
                                        </view>
                                    </view>
                                </view>
                                <view class='icon' @click='edit(item.id)'>
                                    <icon></icon>
                                </view>
                            </view>
                        
                        </block>
                    </view>
                </block>
                <block v-else>
                    <view class='empty'>
                        <view class='img'></view>
                        <text>您还没有添加收货地址哦</text>
                    </view>
                </block>
                <view class='button' @click='addAddress()'>
                    <view class='icon'></view>
                    <view class='text'>新增收货地址</view>
                </view>
            </view>
        </view>
        <cascade-box class="cascade-box" 
            :animationData  = "animationData" 
            :prov           = "prov" 
            :city           = "canArr" 
            :school         = "school" 
            :value          = "cascadeVal" 
            :title          = "true" 
            :notice         = "true" 
            :canShow        = "true" 
            :is_can         = "is_can"
            :column1        = "1"
            :column2        = "1"
            :column3        = "1"
            @cascadeCancel  = "cancelEvent()" 
            @cascadeEnter   = "enterEvent()" 
            @cascadeChange  = "bindChange()"
            @changeIsCan    = "changeIsCan()"
        ></cascade-box>
    </view>    
</template>

<script>
    import Big        from '../../../common/big.js';
	import request    from '../../../common/request.js';
	import $api_base  from '../../../api/api_base.js';
	import topNav     from '@/template/topnav/index.vue';
    import cascadeBox from '@/template/cascade/index.vue';
    import event      from '../../../common/event.js';
    var tmpcar = [];
    var canSelMed = null;
    var is_can_med = null;
    export default {
		components: { topNav,cascadeBox },
        data() {
			return {
                loadOver: true,
                hideOver: true,
                storeId: 0,
                storeInfo: [],
                carList: [],
                groupCar: [],       //拼单信息
                goods_list: [],
                showMore: false,
                mPrice: 0,
                showMj: false,
                yhPrice: 0,
                payPrice: 0, //最后支付价格
                animationData: {},
                canArr: ['无需餐具',1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
                canSel: null,
                address: [],
                remark: '',
                is_pack: 0,
                sid: '',
                aid: 0,
                header:'',
                group_id:'',
                classText: '',
                classTypeList: [],
                classTimeList: [],
                selectClass: [],
                selectDate:'',
                showSelect: false,
                showSelectBtn: false,
                serviceType: 0,
                isRead: true,
                showWxappLogin: false,
                navH: 0,
                n: 0,
                title: '提交订单',
                opacity: 1,
                openOnselfBoxShow:false,
                typeCk:0,
                group_list:[],
                totalCount_all:0,
                group_status:'',
                is_master:false,
                send_price:0,
                master_name:'',
                showRule:false,
                notice_list:[],
                startServiceTime:'',
                selfPhoneNumber:'',
                wxBindPhone:'',
                wxBindPhoneShow:false,
                wrongNumber:false,
                firstOpenOneself:false,
                listServiceType:'',
                showChangeToDe:false,
                priceNoSend: 0, 
                package_fee: 0,
                cascadeVal: [0,1,0],
                is_can:0,
                ISCAN: 0,
                showCanBox: false,
                list:[],
                showAddressBox:false,
                rp_id: 0,
                useful  : [],
                useless : [],
                packet_val:0,
                r_id:'',
                isRegisted: false,
                bindPhone: 0,
                fromPage:'goods',
                packpet_list: [],
                timeIdx:''
            }
        },
        onLoad: function (options) {
            
            let pages     = getCurrentPages();
            let prevPage  = pages[pages.length - 2];
            prevPage.$vm.fromPage = 'storeSearch';
            
            var carList = getApp().carData.carList || [];
            var groupList = getApp().carData.groupList || [];
            var storeInfo = getApp().carData.storeInfo || [];
            var sid = options.sid || '';
            var aid = options.aid || 0;
            var header = options.header || '';
            var group_id = options.groupId || '';
            var is_master = options.is_master== "true" ? true : false;
            var startServiceTime = storeInfo.reserve_start || 0;
            var self = this;
            var serviceType = storeInfo.open_oneself || 0;
            var is_pack = storeInfo.is_pack || 0;
            var title = "提交订单";
            getApp().globalData.listServiceType = options.listServiceType || '';
            tmpcar = [];
            carList.map(function (i) {
                tmpcar.push({
                    id: i.id,
                    orderNum: i.orderNum,
                    discountNum: i.discountNum,
                    showDesc: i.showDesc,
                    stdClass: i.stdClass,
                    num: i.num,
                    box_id: i.box_id,
                    food_box_money: i.food_box_money
                });
            });
            if ( storeInfo.open_oneself == 1 && ( sid == 'oneself' || sid == 'share' || sid == 'qrcode' || sid == 'buy_together' || sid == 'order_list' )) { //oneself 到店自取 
                serviceType = 1;
                if ( startServiceTime == 0 ){
                    this.loadTime();
                    self.showSelectBtn = true;
                }
            }
            if (storeInfo.open_oneself == 0 || sid == 'index' ) { //sid == 'index' 首页
                serviceType = 0;
                self.showSelectBtn = false;
            }
            if (storeInfo.open_oneself == 2) {  //open_oneself
                serviceType = 2;
                if (startServiceTime == 0) {
                    this.loadTime();
                    self.showSelectBtn = true;
                }
            }
            if (sid == 'group' || sid == 'share_group') {  //拼单
                serviceType = 0;
                self.showSelectBtn = false;
            }
            if(header == "buy_together" && !is_master){
                title='好友拼单';
            }else{
                title="提交订单";
            }
            this.title      = title;
            this.sid        = sid;
            this.aid        = aid;
            this.header     = header;
            this.group_id   = group_id;
            this.tmpcar     = tmpcar;
            this.groupCar   = groupList;
            this.is_master  = is_master;
            this.storeInfo  = storeInfo;
            this.is_pack    = is_pack;
            this.storeId    = getApp().carData.storeId;
            this.serviceType= getApp().globalData.listServiceType == '' ? serviceType : getApp().globalData.listServiceType;
            this.navH       = getApp().globalData.navHeight;
            this.n       = getApp().globalData.n;
            this.openId     = uni.getStorageSync('openid');
            this.startServiceTime = startServiceTime;
            this.firstOpenOneself = uni.getStorageSync('FIRST_OPEN_ONESELF');
            if(getApp().globalData.userInfo){
                self.bindPhone = getApp().globalData.userInfo.bind_phone || 0
            }else{
                self.bindPhone = 0;
            }
            self.isRegisted = getApp().globalData.isRegisted;
            if( startServiceTime != 0 ){
                this.loadReserveTime()
                self.showSelectBtn = true;
            }
            if(header == 'buy_together'){
              if (is_master == true) {
                this.loadTogetherOrder(true);
              } else {
                this.loadTogetherInfo();
              } 
            }else{
                this.loadGroupInfo();
                this.loadSettlementOrder(true);
            }   
            event.on('InputRemark', this, function (data) {
                this.remark = data.area;
            });
            
        },
        onShow: function(){     
            var self  = this;
            self.isRegisted = getApp().globalData.isRegisted;
            console.log(this.isRegisted);
            self.showAddressBox = false;
            var ISCAN = uni.getStorageSync("ISCAN");
            self.SCAN = ISCAN; 
            self.is_can = ISCAN;
            if(ISCAN == 2){
              self.canSel = 0;
            }
            if(self.fromPage != 'bind_phone'){
                $api_base.post($api_base.getAddressActive,{},1).then(function(e) {
                    var data = e.data;              
                    if (data.ok == 1) {
                        self.address = {
                            id: data.data.id, 
                            name: data.data.name, 
                            sex: data.data.sex,
                            phone: data.data.phone, 
                            school_type: data.data.school_type, 
                            school_name: data.data.school_name,
                            addr_name: data.data.addr_name, 
                            num: data.data.num,
                            school_id: data.data.school_id
                        };
                        self.notice_list = data.data.notice_list || [];
                    }
                });
            }
            
            if(self.storeInfo.red_count<3 && self.fromPage != 'packet' && self.isRegisted){
                if(self.fromPage == 'bind_phone'){
                    self.loadPacket();
                }else{
                    setTimeout(function(){
                        self.loadPacket();
                    },900);
                }
            }else{
				self.loadOver = false;
				self.hideOver = false;
			}
        },
        methods:{
            packetFilter: function(l){
                var self = this;
                var payPrice   = self.payPrice;      //合计价
                var sendPrice  = self.send_price;    //配送费
                var mPrice     = self.mPrice;        //满减优惠
                var zkPrice    = self.zkPrice;       //折扣优惠
                var schoolId   = self.address.school_id;    //收餐地址学校id
                var phone      = self.address.phone;
                var storeId    = self.storeId;
                var hour       = new Date().getHours();
                var schoolList = getApp().globalData.schoolList[0].regions[0].regions;
                var schoolName = '';
                var serviceType = self.serviceType;    //0外卖订单
                console.log(self.address);
                
                if(self.storeInfo.red_count>2){
                    l.reason = '今日红包次数已用完';
                    self.useless.push(l);
                    return
                }
                if(serviceType == 0 && schoolId == 0){
                    l.reason = '校外地址不能用红包';
                    self.useless.push(l);
                    return
                }
                if(l.store_id !=0 && l.store_id != storeId){        //店铺限制
                    l.reason = '仅限' + l.store_name + '使用';
                    self.useless.push(l);
                    return
                }
                
                if(serviceType == 0 && l.school_id !=0 && l.school_id != schoolId){        //学校限制
                    const index = schoolList.findIndex(item => item.id === l.school_id);
                    if(index<0){
                        l.reason = '该红包可用学校不存在';
                    }else{
                        schoolName = schoolList[index].name;
                        l.reason = '仅限'+schoolName+'使用';
                    }
                    self.useless.push(l);
                    return
                }
                if(l.use_end_time != l.use_start_time){     //有时间段限制
                    if( hour <= l.use_start_time || hour >= l.use_end_time ){
                        l.reason = '仅限' + l.use_start_time + ':00到'+ l.use_end_time +':00使用';
                        self.useless.push(l);
                        return
                    }
                }
                if(serviceType == 0){
                    if(l.oneself == 1){
                        l.reason = '仅限到店自取订单使用';
                        self.useless.push(l);
                        return
                    }
                }else{
                    if(l.oneself == 0){
                        l.reason = '仅限非到店自取订单使用';
                        self.useless.push(l);
                        return
                    }
                }
                if(serviceType == 0 && l.phone != 0 && l.phone != phone){   //收餐手机号限制
                    l.reason = '仅限收货手机号'+ l.phone + '使用';
                    self.useless.push(l);
                }
                if((Number(payPrice) - Number(sendPrice) + Number(mPrice)) < l.full){
                    l.reason = '商品现价+包装费需满'+l.full + '元';
                    self.useless.push(l);
                    return
                }
                if(l.mutex == 1){    //互斥红包 
                    if(mPrice > 0 || zkPrice > 0){
                        l.reason = '不可与满减、折扣商品、第二份半价等其他优惠活动同享';
                        self.useless.push(l);
                        return
                    }
                }
            },
            loadPacket: function(){
                var self = this;
                self.useful = [];
                self.useless = [];
                self.packet_val = 0;
                self.r_id = '';
                var schoolName = '';
                var param = {
                    u_id     : uni.getStorageSync('openid'),
                    p_type   : 3,
                    p_status : 1,
                };  
                $api_base.post($api_base.getRedpacketList,param,1).then(function(res) {
                    let data = res.data;
                    if (data.ok == 1) {
                        var list = data.data.redpocket_list || []; 
                        self.packpet_list = list;
                        if(list.length > 0){    
                                for(let i in list) {
                                    list[i].reason = '';
                                    self.packetFilter(list[i]);
                                    
                                }
                                let useless_id = self.useless.map(item => item.id);
                                let newArr = list.filter(item => !useless_id.includes(item.id));
                                self.useful = newArr;
                        }   
                    }
                    self.loadOver = false; 
                    self.hideOver = false;
                })
            },
            filterArr: function(arr,options){
                
            },
            paySuccess: function () {
                var self = this;
                this.isPay = true;
                uni.showModal({
                    content: "支付成功",
                    showCancel: false,
                    confirmColor: '#00B89D',
                    success: function (res) {
                        if (res.confirm) {
                        //  uni.reLaunch({url: '/pages/order/index?sid=pay_success&from=group&order_no=' + self.orderNo + '&rp_id=' + self.rp_id});
                       uni.reLaunch({url: '/pagesGoods/order-info/index?sid=pay_success&from=group&order_no=' + self.orderNo + '&rp_id=' + self.rp_id});
                        }
                    }
                })
            },
            payError: function (msg) {
                uni.showModal({
                    confirmColor: '#00B89D',content: msg, showCancel: false, success: function (res) {
                        if (res.confirm) {
                            uni.navigateBack();
                        }
                    }
                })
            },
            getPhoneNumber: function(e){
                var self = this;
                self.showWxappLogin = false;
                self.openOnselfBoxShow = false;
                if(getApp().globalData.userInfo.bind_phone == 1){
                    self.loadNewPacket(2);
                }else{
                    var schoolId = getApp().globalData.schoolId;
                    if (e.detail.errMsg == 'getPhoneNumber:ok') {
                        $api_base.post($api_base.getDecryptData,{encryptedData: e.detail.encryptedData, iv: e.detail.iv,school_id: schoolId}).then(function (e) {
                            let data = e.data;
                            if(data.ok == 0){
                                self.isRegisted = false;
                                getApp().globalData.isRegisted = self.isRegisted;
                                uni.showModal({
                                 	title: '',
                                 	content: '注册失败.',
                                 	showCancel: false,
                                 	confirmText: '知道了',
                                 	confirmColor: '#00B89D',
                                 	success(res) {
                                 		if (res.confirm) {
                                 			console.log('用户点击确定')
                                 		} else if (res.cancel) {
                                 			console.log('用户点击取消')
                                 		}
                                 	}
                                })
                            }else{ 
                                self.isRegisted  = true;
                                self.bindPhone  = 1;
                                getApp().globalData.userInfo.bind_phone = 1;
                                getApp().globalData.isRegisted = self.isRegisted;
                                uni.showToast({
                                    title:'注册成功'
                                })
                                self.loadNewPacket(2);
                            }
                        })
                    }else{
                        uni.navigateTo({
                            url:'/pages/index/bind-phone/index?from=buy'
                        })
                        getApp().globalData.isRegisted = self.isRegisted;
                    }
                } 
            },
            loadNewPacket: function(n){
                var self = this;
                var u_id = uni.getStorageSync('openid');
                var r_type = n;
                var school_id = getApp().globalData.schoolId;
                $api_base.post($api_base.getRedpackeNew,{u_id:u_id,r_type:r_type,school_id:school_id},1).then(function(res) {
                	var data = res.data;
                    if(data.ok==1){
                        self.loadPacket();
                    }
                })
            },
            onGetAuthorize: function(res){
                var self = this;
                self.showWxappLogin = false;
                self.openOnselfBoxShow = false;
                my.getPhoneNumber({
                    success: (res) => {
                        let encryptedData = res.response;
                        console.log(res);
                        $api_base.post($api_base.getAliDecryptData,res).then(function (e) {
                            let data = e.data;
                            if(data.ok == 0){    
                                self.isRegisted = false;
                                uni.showModal({
                                 	title: '',
                                 	content: '注册失败.',
                                 	showCancel: false,
                                 	confirmText: '知道了',
                                 	confirmColor: '#00B89D',
                                 	success(res) {
                                 		if (res.confirm) {
                                 			console.log('用户点击确定')
                                            self.loadNewPacket(2);
                                 		} else if (res.cancel) {
                                 			console.log('用户点击取消')
                                 		}
                                 	}
                                })
                            }else{ 
                                self.isRegisted  = true;
                                self.bindPhone  = 1;
                                getApp().globalData.userInfo.bind_phone = 1;
                                getApp().globalData.isRegisted = true
                                uni.showToast({
                                    title:'注册成功'
                                })
                            }
                        })
                    },
                    fail: (res) => {
                        console.log(res);
                        console.log('getPhoneNumber_fail');
                    },
                });
            },
            onAuthError(e) {  
                console.error(e);  
                uni.navigateTo({
                    url:'/pages/index/bind-phone/index?from=index'
                }) 
                getApp().globalData.isRegisted = self.isRegisted;
            },
            // getPhoneNumber: function (e) {
            //     if (e.detail.errMsg == 'getPhoneNumber:ok') {
            //         var self = this;
            //         uni.login({
            //             success: function (res) {
            //                 if (res.code) {
            //                     $api_base.post($api_base.getDecryptData,{
            //                         encryptedData: e.detail.encryptedData, iv: e.detail.iv
            //                     }).then(function (e) {
            //                         let data = e.data;
            //                         if (data.ok == 1) {
            //                             var mobile = data.decriptData.phoneNumber;
            //                             self.openOnselfBoxShow = false;
            //                             $api_base.post($api_base.saveAddress,{
            //                                 name: mobile, 
            //                                 sex: 1, 
            //                                 phone: mobile, 
            //                                 bakPhone: mobile, 
            //                                 school_type: 2,
            //                                 school_id: 0, 
            //                                 addr_name: '自取地址',
            //                                 addr_id: 0, 
            //                                 num: '自取地址'
            //                             }).then(function (e) {
            //                                 let data = e.data;
            //                                 self.isSubmit = true;
            //                                 if (data.ok == 1) {
            //                                     self.showWxappLogin = false;
            //                                     uni.showToast({ title: '登录成功', icon: "none" });
            //                                     $api_base.post($api_base.getAddressActive,{}).then(function (e) {
            //                                         let data = e.data;
            //                                         if (e.ok == 1) {
            //                                             self.address = {
            //                                                     id: data.id, 
            //                                                     name: data.name, 
            //                                                     sex: data.sex,
            //                                                     phone: data.phone, 
            //                                                     school_type: data.school_type, 
            //                                                     school_name: data.school_name,
            //                                                     addr_name: data.addr_name, 
            //                                                     num: data.num
            //                                                 };
            //                                             self.notice_list = data.notice_list || [];
            //                                             self.orderAdd();
            //                                         }
            //                                     });
            //                                 } else {
            //                                    uni.showToast({ title: data.msg, icon: "none" }); 
            //                                 }
            //                             });
            //                         } else {
            //                             self.wxBindPhoneShow = true; 
            //                             self.showWxappLogin  = false;
            //                         }
            //                     });
            //                 } else {
            //                     console.log('登录失败！' + res.errMsg)
            //                 }
            //             }
            //         });
            //     }
            // },
            //联动相关
            selectCan: function () {
                var animation = uni.createAnimation({
                  duration: 300,
                  timingFunction: 'ease'
                });
                var ISCAN = uni.getStorageSync("ISCAN");
                var cansel = this.canSel;
                var cascadeVal = [0, 1, 0];
                animation.height(1332 + 'rpx').step();
                if(cansel == null){
                  cascadeVal =[0,1,0];
                }else{
                  cascadeVal=[];
                  cascadeVal.push(0);
                  cascadeVal.push(cansel);
                  cascadeVal.push(0);
                }
                this.animationData = animation.export();
                this.cascadeVal = cascadeVal;
                canSelMed = cascadeVal[1];
                is_can_med = this.is_can; 
            },
            bindChange: function (e) {
                let val = e.detail.value;
                canSelMed = val[1];
            },
            enterEvent: function () {
                this.canSel = canSelMed;
                var animation = uni.createAnimation({
                  duration: 500,
                  timingFunction: 'ease'
                });
                var is_can = this.is_can;
                this.animation = animation;
                animation.height(0 + 'rpx').step();
                this.animationData = animation.export();
                var self = this;
                if (is_can == 0 && (this.serviceType == 0 || this.is_pack == 0)){
                  // setTimeout(function () {
                  //   self.showCanBox = true;
                  // }, 300)
                  uni.showModal({
                      content: '后续下单您是否都需要餐具？(依据餐量提供)',
                      confirmText: '需要',
                      cancelText: '不需要',
                      confirmColor: '#00B89D',
                      success(res) {
                          if (res.confirm) {   
                              self.confirmCanBox();
                          } else if (res.cancel) {
                              self.closeCanBox();
                          }
                      }
                  })
                }
            },
            cancelEvent: function () {
                var canSel = this.canSel;
                var animation = uni.createAnimation({
                  duration: 500,
                  timingFunction: 'ease'
                })
                animation.height(0 + 'rpx').step();
                this.animationData = animation.export();
                this.canSel = canSel;
                this.cascadeVal = [0, 1, 0];
                this.is_can = is_can_med;
            },
            submitAdd: function(){
                var self = this;
                var serviceType = self.serviceType || 0;
                var notice_list = self.notice_list;
                var header = self.header;
                var sid = self.sid;
                var notice_type = 0;
                var notice_content = '';
                if (serviceType == 0) {
                    if (header == 'buy_together')
                        notice_type = 3;    //拼单订单
                    else
                        notice_type = 1;    //正常配送订单
                    if (sid == 'group' || sid == 'share_group')
                        notice_type = 2;    //  开车订单
                }
                if (notice_list && notice_list.length > 0) {
                    for (let i in notice_list) {
                        if (notice_type == notice_list[i].type) {
                            notice_content = notice_list[i].notice;
                            if (notice_content != '') {
                                uni.showModal({
                                    content: notice_content,
                                    confirmText: '继续下单',
                                    cancelText: '取消',
                                    confirmColor: '#00B89D',
                                    success(res) {
                                        if (res.confirm) {
                                            self.orderAdd();
                                        } else if (res.cancel) {
                                            return false
                                        }
                                    }
                                })
                            }
                        }
                    }
                    if(notice_content == '')
                        self.orderAdd();
                }else{
                    self.orderAdd();
                }
            },
            orderAdd: function () {
                var isRegisted = this.isRegisted;
                var address = this.address;
                var storeId = this.storeId;
                var carList = [];
                var groupUniqueId = '';
                var canSel = this.canSel;
                var remark = this.remark || '';
                var is_pack = this.is_pack || 0;
                var serviceType = this.serviceType || 0;
                var serviceTime = '';
                var self = this;
                var header = self.header;
                var tmpcar = [];
                var group_id = self.group_id || 0;
                var sid = self.sid;
                var startServiceTime = self.startServiceTime;
                var ISCAN = uni.getStorageSync("ISCAN");
                var is_can = this.is_can;
                if (this.serviceType > 0) {
                    if (!this.isRead) {
                        uni.showToast({ title: '请先同意《到店自取服务协议》', icon: "none" })
                        return false;
                    }
                }
                if (ISCAN == 0 && this.canSel == null && (this.serviceType == 0 || this.is_pack == 0)){
                    this.selectCan();
                    return false
                }
                if (ISCAN == 1 && !this.canArr[canSel]) {
                    canSel = "依据餐量提供";
                } else {
                    canSel = this.canSel === null ? 0 : parseInt(this.canSel);
                }
                uni.setStorageSync('ISCAN', is_can);
                if(header == 'buy_together'){
                    carList = self.goods_list;
                    carList.map(function (i) {
                        tmpcar.push({
                            id: i.id,
                            orderNum: i.orderNum,
                            discountNum: i.discountNum,
                            name: i.name,
                            stdClass: i.stdClass,
                            key: i.key,
                            num: i.num,
                            desc: i.desc,
                            showDesc: i.showDesc,
                            box_id: i.box_id,
                            food_box_money: i.food_box_money
                        });
                    });
                }else{
                    carList = getApp().carData.carList;
                    carList.map(function (i) {
                        tmpcar.push({
                            id: i.id,
                            orderNum: i.orderNum,
                            discountNum: i.discountNum,
                            name: i.goods.name,
                            stdClass: i.stdClass,
                            key: i.key,
                            num: i.num,
                            desc: i.desc,
                            showDesc: i.showDesc,
                            box_id: i.box_id,
                            food_box_money: i.food_box_money
                        });
                    });
                }
                var car_list = JSON.stringify(tmpcar);
                if (carList.length <= 0 || storeId <= 0) {
                    uni.showToast({ title: '订单提交错误', icon: "none" });
                    return false;
                }
                if (self.selectClass == '' && self.showSelectBtn) {
                    var title = this.serviceType > 0 ? '自取' : '预计送达';
                    uni.showToast({title: '请选择'+ title +'时间', icon: "none"});
                    return false;
                }
                if (sid == 'group' || sid == 'share_group')
                    serviceTime = this.selectDate + ' ' +this.selectClass.finish_time; //开车送达时间
                else
                    serviceTime = this.selectClass;  //自取/送达时间

                // if (address.length <= 0 && this.serviceType > 0) {
                //     this.showWxappLogin = true;
                //     return false;
                // }
                // if (address.length <= 0) {
                //     uni.showToast({title: '请添加收货地址', icon: "none"});
                //     return false;
                // }
                if (!isRegisted && this.serviceType > 0) {
                    this.showWxappLogin = true;
                    return false;
                }
                if (address.length <= 0 && this.serviceType == 0) {
                    uni.showToast({title: '请添加收货地址', icon: "none"});
                    return false;
                }
                    var sid = this.sid;
                    var buyId = 1;
                    if (sid === 'group' || sid === 'share_group') {
                        groupUniqueId = this.selectClass.unique_id || '';
                        buyId = 2;
                    }
                    this.closeOpenOnselfBox();
                    $api_base.post($api_base.addOrder,{
                        store_id        : storeId,
                        address_id      : address.id,
                        can_sel         : canSel,
                        remark          : remark,
                        is_pack         : is_pack,
                        car_list        : car_list,
                        sid             : sid,
                        aid             : this.aid,
                        group_unique_id : groupUniqueId,
                        service_type    : is_pack == 1 && serviceType > 0 ? 3 : serviceType,
                        service_time    : serviceTime,
                        reserve_order_send_time: startServiceTime == 0 ? '' : serviceTime,
                        group_id        : group_id,
                        school_id       : getApp().globalData.schoolId,
                        red_id            : this.r_id
                    }).then(function (e) {
                        let data = e.data;
                        if (data.ok == 1) {
                            self.orderNo = data.order_no;
                            self.rp_id   = data.rp_id || 0;
                            $api_base.post($api_base.payConfirm,{
                                _sid: 'orderpay', 
                                order_no: data.order_no,
                                buy_id: buyId, 
                                buy_num: 1, 
								// #ifdef  MP-ALIPAY
                                pay_type: 2, 
								// #endif
								// #ifdef MP-WEIXIN
								 pay_type: 1, 
								// #endif
                                open_id: uni.getStorageSync('openid')
                            }).then(function (data) {
                                let e = data.data;
								// #ifdef  MP-ALIPAY
								if(e.ok == 1){
										uni.requestPayment({
										provider: 'alipay',
										orderInfo: e.nonceStr+'',
										success: function(res) {
											if (res.resultCode == 6001) {
												self.payError("支付失败")
											} else if(res.resultCode == 9000){
											    self.paySuccess();
											}else{
												self.payError("支付失败")
											}
											console.log('success:' + JSON.stringify(res));
										},
										fail: function(err) {
											self.payError("支付失败")			
											console.log('fail:' + JSON.stringify(err));
										}
									});
								}
								// #endif
								// #ifdef MP-WEIXIN
                                if (e.ok == 1 && e.sign != undefined) {
                                    uni.requestPayment({
                                        'timeStamp': e.timeStamp + '',
                                        'nonceStr': e.nonceStr,
                                        'package': e.package,
                                        'signType': e.signType,
                                        'paySign': e.sign,
                                        'success': function (res) {
                                            if (res.errMsg == 'requestPayment:ok') {
                                                self.paySuccess();
                                            } else {
                                                self.payError("支付失败")
                                            }
											console.log('success:' + JSON.stringify(res));
                                        },
                                        'fail': function (res) {
                                            if (res.errMsg == 'requestPayment:fail cancel') {
                                                //取消支付
                                            } else {
                                                self.payError("支付失败")
                                            }
											console.log('success:' + JSON.stringify(res));
                                        }
                                    })
                                } 
								// #endif
								else {
                                    self.payError(e.msg)
                                }
                            });
                        } else if (data.ok == 2) {
                            uni.showModal({
                                confirmColor: '#00B89D',content: data.msg, showCancel: false, success: function (res) {
                                    if (res.confirm) {
                                        event.emit('selOutReload', { id: data.id, key: data.key, num: data.num });
                                    }
                                }
                            })
                        } else if (data.ok == 3) { //团购活动停止
                            uni.showModal({
                                confirmColor: '#00B89D',confirmColor: '#00B89D',content: data.msg, showCancel: false, success: function (res) {
                                    if (res.confirm) {
                                        event.emit('groupReload');
                                    }
                                }
                            })
                        } else {
                            uni.showModal({
                                confirmColor: '#00B89D',
                                content: data.msg,
                                showCancel: false,
                                success: function (res) {
                                }
                            })
                        }
                    });
            },
            loadGroupInfo: function () {
                var self = this;
                if (this.sid == 'group' || this.sid == 'share_group') {
                    $api_base.post($api_base.getGroupInfo,{store_id: getApp().carData.storeId}).then(function (e) {
                        let data = e.data;
                        if (data.ok == 1) {
                            var currentInfo = data.current_class_info || null;
                            var isOpen = currentInfo.is_open || 0;
                            if (isOpen > 0) {
                                var classList = currentInfo.class_list || [];
                                var classTypeList = [];
                                var classTimeList = [];
                                var selectClass = [];
                                var selectDate = '';
                                if (classList.length > 0) {
                                    classList.map(function (i, k) {
                                        var isCurrent = 0;
                                        if (k === 0) {
                                            selectDate = i.text;
                                            classTimeList = i.data;
                                            selectClass = i.data[0];
                                            isCurrent = 1;
                                        }
                                        i.current = isCurrent;
                                        classTypeList.push(i);
                                    });
                                }
                                self.classTypeList = classTypeList; 
                                self.showSelectBtn = false; 
                                self.selectClass = selectClass;
                                self.selectDate = selectDate;
                            } else {
                                uni.showModal({
                                    content: '暂无活动',
                                    showCancel: false,
                                    confirmColor: '#00B89D',
                                    success: function (res) {
                                        event.emit('groupReload');
                                        uni.navigateBack();
                                    }
                                });
                            }
                        }
                    });
                }
            },
            loadSettlementOrder: function (mask) {
                var self = this;
                var mPrice = 0;   //满减优惠
                var payPrice = 0;//支付价格
                var yhPrice = 0;//总优惠
                var zkPrice = 0;//折扣优惠
                var is_disable_m_goods = 0;
                var priceNoSend = 0;
                var send_price = 0;
                var package_fee = 0;
                var is_pack = self.is_pack;
                var groupCar = [];
                for(let i in self.groupCar){
                    for(let j in self.groupCar[i].goods_list){
                        groupCar.push(self.groupCar[i].goods_list[j]);
                    } 
                }
                var car_list = JSON.stringify(tmpcar) == '[]' ? JSON.stringify(groupCar) : JSON.stringify(tmpcar);
                $api_base.post($api_base.settlementOrder,{
                    store_id: getApp().carData.storeId,
                    car_list: car_list,
                    service_type: is_pack == 1 && self.serviceType > 0 ? 3 : self.serviceType
                }, mask).then(function (data) {
                    let e = data.data;
                    if (e.ok == 1) {
                        mPrice = e.result.m_price;
                        yhPrice = e.result.yh_price;
                        payPrice = e.result.result_price;
                        zkPrice = e.result.zk_price;
                        is_disable_m_goods = e.result.is_disable_m_goods;
                        priceNoSend = e.result.total_price || 0;
                        send_price = e.result.send_price;
                        package_fee = e.result.food_box_money + e.result.package_bag_money;
                        package_fee = new Big(package_fee).round(2).toString();
                        self.is_disable_m_goods = is_disable_m_goods; 
                        self.goods_list = e.result.goods_list;
                        self.mPrice = mPrice; 
                        self.yhPrice = yhPrice; 
                        self.zkPrice = zkPrice; 
                        self.payPrice = parseFloat(payPrice);
                        self.priceNoSend = priceNoSend; 
                        self.send_price = send_price; 
                        self.package_fee = package_fee;
                    } else {
                        uni.showModal({
                            content: e.msg,
                            showCancel: false,
                            confirmColor: '#00B89D',
                            success: function (res) {
                            }
                        });
                    }
                });
            },
            loadTogetherInfo: function(mask){
                var self = this;
                var groupArray = [];
                var totalCount_all = 0;
                var payPrice = 0;
                var is_master = false;
                var header = '';
                var package_fee = 0;
                $api_base.post_new($api_base.groupInfo,{ wxapp_id: self.openId, group_id: self.group_id}, mask).then(function (e) {
                    let data = e.data;
                    if (data.ok == 1) {
                        groupArray = data.data;
                        var goods_list = data.order_list || [];
                        for (let i in groupArray) {
                                totalCount_all += groupArray[i].goods_list.length;
                           // send_price = data.send_price == '0.00' ? '0' : data.send_price;
                        }
                        if (data.master_id != '') header = 'buy_together';
                        if (data.master_id == self.openId) {
                            is_master = true;   
                        } else {
                            is_master = false;
                        }
                        let result_price    = data.total_money;   //发起人提交前价格没有进行优惠计算，总价为total_money
                        payPrice            = new Big(result_price).round(2).toString();
                        package_fee         = data.food_box_money + data.package_bag_money;
                        package_fee         = new Big(package_fee).round(2).toString();
                        self.group_list     = data.data;
                        self.totalCount_all = totalCount_all;
                        self.payPrice       = parseFloat(payPrice);
                        self.group_status   = data.group_status;
                        self.goods_list     = goods_list;
                        self.master_name    = data.master_name;
                        self.is_master      = is_master;
                        self.header         = header;
                        self.package_fee    = package_fee;
                        self.send_price     = data.send_price;
                        self.yhPrice        = data.group_money.yh_price || 0;
                        self.mPrice         = data.group_money.m_price || 0;
                    }
                });
            },
            loadTogetherOrder: function (mask) {
                var self = this;
                var send_price = 0;
                var mPrice     = 0;   //满减优惠
                var payPrice   = 0;  //支付价格
                var yhPrice    = 0;  //总优惠
                var zkPrice    = 0;  //折扣优惠
                var is_disable_m_goods = 0;
                var serviceType = self.serviceType;
                var is_pack = self.is_pack;
                $api_base.post($api_base.submitGroup,{ 
                    wxapp_id: self.openId, 
                    group_id: self.group_id, 
                    service_type: is_pack == 1 && self.serviceType > 0 ? 3 : serviceType 
                }, mask).then(function (res) {
                    let e = res.data
                    if (e.ok == 1) {
                        var goods_list  = e.result.goods_list || [];
                        mPrice          = e.result.m_price;
                        yhPrice         = e.result.yh_price;
                        payPrice        = e.result.result_price;
                        zkPrice         = e.result.zk_price;
                        send_price      = e.result.send_price;
                        is_disable_m_goods = e.result.is_disable_m_goods;
                        self.is_disable_m_goods = is_disable_m_goods;
                        self.mPrice     = mPrice;
                        self.yhPrice    = yhPrice;
                        self.zkPrice    = zkPrice;
                        self.payPrice   = payPrice;
                        self.send_price = send_price;
                        self.loadTogetherInfo(1);
                    }else{
                        uni.showToast({ title: e.msg, icon: "none", duration: 2000 })
                        return false;
                    }
                })
            },
            addressList: function () {
                uni.navigateTo({
                    url: '/pages/address/index?fromPage=buy'
                })
            },
            addressEvent: function (n) {
                var self = this;
                if(n==1){
                    uni.navigateTo({ url: '/pagesBuy/address-edit/index' });
                }else{
                    self.showAddressBox = true;
                    self.getAddress();
                }
                
            },
            closeAddressBox: function(){
                this.showAddressBox = false;
            },
            getAddress: function(){
                var self = this;
                $api_base.post($api_base.getAddress,{},1).then(function(res){
                    let data = res.data;
                    self.list = data.list 
                })
			},
            active: function (e) {
                var self = this;
                let item = e;
				var id = item.id;
                self.address = item;
                this.showAddressBox = false;
				$api_base.post($api_base.activeAddress,{id: id },1).then(function(res){
					let data = res.data;
                    self.loadPacket();
					//self.getAddress();
				});
			},
            edit: function (e) {
				var id = e;
				uni.navigateTo({ url: '/pagesBuy/address-edit/index?id=' + id });
			},
            addAddress: function () {
				if (this.list.length >= 5) {
				  uni.showToast({ title: "最多只能添加5个", icon: "none" });
				  return false;
				}
				uni.navigateTo({ url: '/pagesBuy/address-edit/index' })
			},   
            showMoreF: function(e) {
                if (this.showMore) {
                    this.showMore = false;
                } else {
                    this.showMore = true;
                }
            },
            changeIsPack: function(e) {
                var is_pack = e;
                if (is_pack == 0){
                    setTimeout(function () {
                      uni.showToast({ title: '用餐方式发生变化，已为您调整包装费', icon: 'none', duration: 2000 });
                    }, 400)
                }
                this.is_pack = is_pack;  
                if (this.header == "buy_together") {
                    this.loadTogetherOrder(1)
                } else {
                    this.loadSettlementOrder(1);
                }
            },
            changeIsCan: function(e){
                var e = e;
                var is_can = this.is_can;
                if( e == is_can){
                    is_can = 0;
                }else{
                    is_can = e;
                }
                this.is_can = is_can;  
            },
            selectTimeEvent: function (e) {
                let idx = e.currentTarget.dataset.idx;
                let classTimeList = this.classTimeList;
                let list = this.classTypeList;
                let selectClass = '';
                let startServiceTime = this.startServiceTime;
                this.timeIdx = idx;
                if( startServiceTime != 0){
                    list.map(function (i, k) {
                        if (i.current == 1) {
                            selectClass = i.date_day;
                            return false
                        }
                    });
                    selectClass = selectClass + classTimeList[idx];
                }else{
                    selectClass = classTimeList[idx].finish_time;
                } 
                this.selectClass = selectClass; 
                this.showSelect = false;
            },
            selectTypeEvent: function (e) {
                let idx = e.currentTarget.dataset.idx;
                let list = this.classTypeList;
                let classTypeList = [];
                list.map(function (i, k) {
                    if (idx == k) i.current = 1;
                    else i.current = 0;
                    classTypeList.push(i);
                });
                let data = list[idx];
                this.classTypeList = classTypeList;
                this.classTimeList = data.data;
                this.timeIdx = -1;
            },
            selectClassEvent: function () {
                if (this.showSelectBtn === false) return false;
                this.showSelect = true;
            },
            closeClassEvent: function () {
                this.showSelect = false;
            },
            remarkEvent: function () {
                uni.navigateTo({url: '/pagesBuy/buy/remark/index?remark=' + this.remark});
            },
            readRemark: function () {
                uni.setStorageSync('BUY_READ', this.isRead);
                this.isRead = !this.isRead;
            },
            goRemark: function () {
                uni.navigateTo({
                    url: '/pagesBuy/buy/user-protocol/index'
                })
            },
            goMobile: function () {
                uni.makePhoneCall({
                    phoneNumber: this.storeInfo.mobile
                });
            },
            serviceTypeEvent: function (e) {
                var id = e;
                var startServiceTime = this.startServiceTime;         
                var typeCk = this.typeCk
                var storeInfo = this.storeInfo;
                var priceNoSend = this.priceNoSend;
                var is_master = this.is_master;
                if (this.serviceType == id) return false;
                if (id > 0) {               //到店自取
                    this.serviceType = id;
                    if (startServiceTime == 0){
                        this.loadTime();  
                        this.showSelectBtn = true;
                    }
                    if(this.header=="buy_together"){
                      if (is_master == true) {             
                        this.loadTogetherOrder(true)
                      } else {
                        this.loadTogetherInfo()
                      } 
                    }else{
                        this.loadSettlementOrder(true);
                    }
                } else {    //外卖配送
                    if (priceNoSend < storeInfo.start_send_price && !is_master){
                        this.showChangeToDe = true;
                        return false
                    }
                    this.serviceType = id;
                    this.showSelectBtn = false;
                    if (this.header == "buy_together") {
                        if (is_master == true) {
                          this.loadTogetherOrder(true)
                        } else {
                          this.loadTogetherInfo()
                        }    
                    } else {
                        this.loadGroupInfo();
                        this.loadSettlementOrder(true);
                    }  
                    setTimeout(function(){
                        uni.showToast({ title: '用餐方式发生变化，已为您调整配送费', icon: 'none', duration: 2000 });
                    },400)  
                }
                getApp().globalData.listServiceType = this.serviceType;
                typeCk++;
                this.typeCk = typeCk;
                if ( startServiceTime != 0 ){
                    this.showSelectBtn = true;
                    this.loadReserveTime()
                }
                var self = this;
                setTimeout(function(){
                    self.loadPacket();
                },400)  
            },
            loadTime: function () {   //原自取时间
                var self = this;
                $api_base.post($api_base.getSelfTime,{}).then(function (e) {
                    let data = e.data;
                    if (data.ok == 1) {
                        var classList = data.time_list || [];
                        var classTypeList = [];
                        var classTimeList = [];
                        var selectClass = [];
                        if (classList.length > 0) {
                            classList.map(function (i, k) {
                                var isCurrent = 0;
                                if (k === 0) {
                                    classTimeList = i.data;
                                    selectClass = i.data[0].finish_time;
                                    isCurrent = 1;
                                }
                                i.current = isCurrent;
                                classTypeList.push(i);
                            });
                        }
                        self.classTypeList = classTypeList;
                        self.classText = '选择自取时间';
                        self.classTimeList = classTimeList;
                        self.selectClass = selectClass;
                    }
                });
            },
            loadReserveTime: function(){   //   预定时间
                var self = this;
                var is_self = 0;
                is_self = self.serviceType == 0 ? 2 : 1;
                var storeInfo = self.storeInfo;
                $api_base.post($api_base.getTime,{ store_id: getApp().carData.storeId, is_self: is_self }).then(function (e) {
                    let data = e.data;
                    if (data.ok == 1) {
                        var classList = data.data || [];
                        var classTypeList = [];
                        var classTimeList = [];
                        var selectClass = [];
                        if (classList.length > 0) {
                            classList.map(function (i, k) {
                                var isCurrent = 0;
                                if (k === 0 && i.time_list && i.time_list.length>0) {
                                    if (storeInfo.disable == 1){    //暂停营业
                                        i.time_list.forEach(function (item, index, arr) {
                                            if (item == '尽快送达' || item == '即刻取餐') {
                                                arr.splice(index, 1);
                                            }
                                        });
                                    }
                                    if (i.time_list[0] == '尽快送达' || i.time_list[0] == '即刻取餐'){
                                        selectClass = i.time_list[0];
                                    }else{
                                       // selectClass = i.date_day + i.time_list[0];
                                       selectClass = [];
                                    }
                                    classTimeList = i.time_list;  
                                    isCurrent = 1;
                                }
                                i.current = isCurrent;
                                let text = i.date_day + i.date_week;
                                classTypeList.push({
                                    current: isCurrent,
                                    text : text,
                                    date_day: i.date_day,
                                    send_price : i.send_price,
                                    data: i.time_list
                                    });
                            });
                        }
                        let classText = is_self == 1 ? '选择自取时间' : '选择送达时间';
                        self.classTypeList = classTypeList; 
                        self.classText = classText;
                        self.classTimeList = classTimeList;
                        self.selectClass = selectClass;
                    }else{  //店铺不支持预定
                        self.showSelectBtn = false;
                    }
                });
            },
            openStore: function (e) {
                console.log(e);
              //  var storeId = e.currentTarget.dataset.storeid;
                uni.navigateBack();
            },
            closeOpenOnselfBox: function () {
                this.openOnselfBoxShow = false;
            },
            showOpenOnselfBox: function () {
                var ISCAN = uni.getStorageSync("ISCAN");
                if (this.serviceType > 0) {
                    if (!this.isRead) {
                      uni.showToast({ title: '请先同意《到店自取服务协议》', icon: "none"})
                        return false;
                    }
                    if (this.is_pack != 0 && this.is_pack != 1 ){
                        uni.showToast({ title: '请先选择堂食或打包', icon: "none" })
                        return false;
                    }
                  if (ISCAN == 0 && this.canSel == null && (this.serviceType == 0 || this.is_pack == 0)) {
                      this.selectCan();
                      return;
                  }
                }
                this.openOnselfBoxShow = true; 
                this.firstOpenOneself = true;  
                uni.setStorageSync('FIRST_OPEN_ONESELF', this.firstOpenOneself);
            },
            outGroup: function(){      //退出拼单
                var self = this;
                var storeId = self.storeId;
                app.HttpServiceNew.groupInfo({ wxapp_id: self.openId, group_id: self.group_id }).then(function (data) {
                    if (data.ok == 1) {
                        if(data.group_status == 1){
                            app.HttpServiceNew.outGroup({ wxapp_id: self.openId, group_id: self.group_id }).then(function (data) {
                                if (data.ok == 1) {
                                    uni.showToast({ title: '退出拼单成功', icon: 'none', duration: 2000 });
                                    let pages = getCurrentPages();      //获取当前页面js里面的pages里的所有信息。
                                    let prevPage = pages[pages.length - 2]; //prevPage 是获取上一个页面的js里面的pages的所有信息。 -2 是上一个页面，-3是上上个页面以此类推。
                                    prevPage.$vm.header = ''
                                    prevPage.$vm.prevPagenavigationClose = false;
                                    prevPage.$vm.group_id = 0; 
                                    prevPage.$vm.groupList = []; 
                                    prevPage.$vm.carList = tmpcar; 
                                    prevPage.$vm.totalCount = 0; 
                                    prevPage.$vm.totalPrice = 0; 
                                    prevPage.$vm.isOut = true;
                                    setTimeout(function () {
                                        uni.navigateBack({
                                            url: '/pages/goods/goods'
                                        })
                                    },1000)
                                } else {
                                    return false;
                                }
                            });
                        }else{
                            uni.showToast({ title: '发起人已提交了订单，您不能退出拼单', icon: 'none', duration: 2000 });
                            return false;
                        }
                    }
                }); 
            },
            changeGroup: function () {      //修改商品
                var self = this;
                var storeId = self.storeId;
                var group_id = self.group_id;
                var header = self.header;
                var is_master = self.is_master;
                if ( is_master == true ){
                    uni.navigateBack({  url: '/pages/goods/goods' })
                }else{
                    app.HttpServiceNew.groupInfo({ wxapp_id: self.data.openId, group_id: group_id }).then(function (data) {
                        if (data.ok == 1) {
                            if (data.group_status == 1) {
                                uni.navigateBack({
                                    url: '/pages/goods/goods'
                                })
                            } else {
                                uni.showToast({ title: '发起人已提交了订单，您不能修改商品', icon: 'none', duration: 2000 });
                                return false;
                            }
                        }
                    }); 
                } 
            },
            showTip: function () {
                this.showRule = true;
            },
            closeShowRule: function () {
                this.showRule = false;
            },
            phoneEvent: function (e) {
                var value = e.detail.value;
                this.wxBindPhone = value;
            },
            closeWxBindPhoneShow: function(){
                var self = this;
                var mobile = self.wxBindPhone;
                if (!mobile || mobile.length != 11){
                    self.wrongNumber = true;
                    return false
                }
                self.wxBindPhoneShow = false; 
                self.wrongNumber = false;
                $api_base.post($api_base.saveAddress,{
                    name: mobile, sex: 1, phone: mobile, bakPhone: mobile, school_type: 2,
                    school_id: 0, addr_name: '自取地址', addr_id: 0, num: '自取地址'
                }).then(function (res) {
                    let data = res.data;
                    self.isSubmit = true;
                    if (data.ok == 1) {
                        self.showWxappLogin = false;
                        uni.showToast({ title: '登录成功', icon: "none" });
                        $api_base.post($api_base.getAddressActive,{}).then(function (data) {
                            let e = data.data;
                            if (e.ok == 1) {
                                self.address = {
                                        id          : data.id, 
                                        name        : data.name, 
                                        sex         : data.sex,
                                        phone       : data.phone, 
                                        school_type : data.school_type, 
                                        school_name : data.school_name,
                                        addr_name   : data.addr_name, 
                                        num         : data.num,
                                        school_id   : data.school_id
                                    };
                                self.notice_list = data.notice_list || []
                                self.orderAdd();
                            }
                        });
                    } else {
                        uni.showToast({ title: data.msg, icon: "none" });
                    }
                });
            },
            closeToDe:function (e){
                var id = e;
                if(id == 1){
                    let pages = getCurrentPages();    
                    let prevPage = pages[pages.length - 2]; 
                    prevPage.$vm.sid = 'de';
                    getApp().globalData.listServiceType = 0;
                    uni.navigateBack({
                            url: '/pages/goods/goods'
                    })
                }
                this.showChangeToDe = false;
            },
            closeCanBox:function(){
                this.is_can = 2;
                this.showCanBox =false;
            },
            confirmCanBox:function(){
                this.is_can = 1;
                this.showCanBox = false;
            },
            goRedPacket:function(){
                var storeId = this.storeId;
                uni.navigateTo({
                    url: '/pagesBuy/buy/red-packet/index?storeId=' + storeId
                })
            }
        },
        // #ifdef MP-WEIXIN
        onPageScroll(){
        	var self = this;
        	const query1 = uni.createSelectorQuery();
        	query1.select('.content').boundingClientRect();
        	query1.selectViewport().scrollOffset();
        	query1.exec(function(res){ 
        		let top = res[0].top;
                if(self.storeInfo.open_oneself > 0){
                    if(top<-80){
                        if(self.serviceType > 0 && self.sid != 'group' && self.sid !='share_group'){
                            self.title = self.storeInfo.address;
                        }else{
                            self.title = self.address.addr_name + self.address.num;
                        }
                        self.opacity = (top+80)/-80;
                    }else{
                    	self.title = '提交订单';
                        self.opacity = (top+80)/80;
                    }                   
                }
                if(self.storeInfo.open_oneself == 0 || self.sid=="group" || self.sid=="share_group"){   //顶部没有tab
                    if(top<-36){
                        self.title = self.address.addr_name + self.address.num;
                         self.opacity = (top+36)/-36;
                    }else{
                        self.title = '提交订单';
                        self.opacity = (top+36)/36;
                    }  
                }
        	});
        }
        // #endif
    }
</script>
<style>
    page{
        background: linear-gradient(to bottom, #fff 0%,#f9f9f9 30%);
    }
</style>
<style lang="scss" scoped>
	@import 'index.scss';
    @import '../../../pages/address/index.scss';
</style>
